package com.backend.demo1.config;

import com.backend.demo1.middlewares.JwtMiddleware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.lang.NonNull; // 导入 Spring 的 NonNull 注解

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private JwtMiddleware jwtMiddleware;

    @Override
    public void addInterceptors(@NonNull InterceptorRegistry registry) {
        // 拦截 /api/auth/protected 路径
        registry.addInterceptor(jwtMiddleware).addPathPatterns("/hello");
    }
}